﻿/*----------------------------------------------------------------
//  <copyright file="IFilterService.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2023-07-15 10:40</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Filter
{
    #region "过滤表达式功能接口"
    /// <summary>
    /// 过滤表达式功能接口
    /// </summary>
    public interface IFilterService
    {
        #region "方法"
        #region "获取指定查询条件组的查询表达式"
        /// <summary>
        /// 获取指定查询条件组的查询表达式
        /// </summary>
        /// <typeparam name="T">表达式实体类型</typeparam>
        /// <param name="group">
        /// 查询条件组
        /// <para>如果为 null，则直接返回 true 表达式。</para>
        /// </param>
        /// <returns>查询表达式</returns>
        Expression<Func<T, bool>> GetExpression<T>(FilterGroup group);
        #endregion
        #region "获取指定查询条件的查询表达式"
        /// <summary>
        /// 获取指定查询条件的查询表达式
        /// </summary>
        /// <typeparam name="T">表达式实体类型</typeparam>
        /// <param name="rule">
        /// 查询条件
        /// <para>如果为 null，则直接返回 true 表达式。</para>
        /// </param>
        /// <returns>查询表达式</returns>
        Expression<Func<T, bool>> GetExpression<T>(FilterRule rule);
        #endregion
        #region "获取指定查询条件组的查询表达式并综合数据权限"
        /// <summary>
        /// 获取指定查询条件组的查询表达式并综合数据权限
        /// </summary>
        /// <typeparam name="T">实体类型</typeparam>
        /// <param name="group">
        /// 传入的查询条件组
        /// <para>为空时则只返回数据权限过滤器</para>
        /// </param>
        /// <param name="operation">数据权限操作</param>
        /// <returns>综合之后的表达式</returns>
        Expression<Func<T, bool>> GetDataFilterExpression<T>(FilterGroup group = null, DataAuthOperation operation = DataAuthOperation.Read);
        #endregion
        #region "验证指定查询条件组是否能正常转换为表达式"
        /// <summary>
        /// 验证指定查询条件组是否能正常转换为表达式
        /// </summary>
        /// <param name="group">查询条件组</param>
        /// <param name="type">实体类型</param>
        /// <returns>验证操作结果</returns>
        OperationResult CheckFilterGroup(FilterGroup group, Type type);
        #endregion

        #endregion

    }
    #endregion

}
